{
  user.services =
    builtins.mapAttrs
      (name: value: {
        Unit = {
          Description = value.Unit.Description or pkgs.${name}.meta.description;
          PartOf = [ config.wayland.systemd.target ];
          After = [ config.wayland.systemd.target ];
          X-Restart-Triggers = value.Unit.X-Restart-Triggers or [ ];
        };
        Service = value.Service // {
          Restart = "on-failure";
        };
        Install.WantedBy = [ config.wayland.systemd.target ];
      })
      {
        swayidle = {
          Unit.X-Restart-Triggers = [ config.xdg.configFile."swayidle/config".source ];
          Service.ExecStart = lib.getExe pkgs.swayidle + " -w";
        };
        system76-scheduler-niri = {
          Unit.Description = "Niri integration for system76-scheduler";
          Service.ExecStart = pkgs.writeScript "system76-scheduler-niri" ''
            #!/bin/sh
            set -euo pipefail
            niri msg --json event-stream | while read -r line; do
                event=$(echo "$line" | jq -c '.WindowFocusChanged // empty')
                if [ -z "$event" ]; then
                    continue
                fi
                pid=$(niri msg --json focused-window | jq '.pid // empty')
                if [ -z "$pid" ]; then
                    continue
                fi
                busctl --system -- call com.system76.Scheduler /com/system76/Scheduler com.system76.Scheduler SetForegroundProcess u "$pid"
            done
          '';
        };
      };
}
